import { defHttp } from '@/utils/http/axios';
import { RequestEnum } from '@/enums/httpEnum';
import { ServicePrefixEnum } from '@/enums/commonEnum';
import type { AxiosRequestConfig } from 'axios';

const MODULAR = '/system/sms-channel';

export const Api = {
  GetSmsChannelPage: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetSimpleSmsChannelList: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/simple-list`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetSmsChannel: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  CreateSmsChannel: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/create`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  UpdateSmsChannel: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/update`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  DeleteSmsChannel: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/delete`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,
}


// 查询短信渠道列表
export const getSmsChannelPage = (params) => {
  return defHttp.request({ ...Api.GetSmsChannelPage,params})
}

// 获得短信渠道精简列表
export function getSimpleSmsChannelList() {
  return defHttp.request({ ...Api.GetSimpleSmsChannelList})
}

// 查询短信渠道详情
export const getSmsChannel = (id: number) => {
  return defHttp.request({ ...Api.GetSmsChannel,params:{id}})
}

// 新增短信渠道
export const createSmsChannel = (data: SmsChannelVO) => {
  return defHttp.request({ ...Api.CreateSmsChannel,params:data})
}

// 修改短信渠道
export const updateSmsChannel = (data: SmsChannelVO) => {
  return defHttp.request({ ...Api.UpdateSmsChannel,params:data})
}

// 删除短信渠道
export const deleteSmsChannel = (id: number) => {
  return defHttp.request({ ...Api.DeleteSmsChannel,params:{id}})
}

export interface SmsChannelVO {
  id: number
  code: string
  status: number
  signature: string
  remark: string
  apiKey: string
  apiSecret: string
  callbackUrl: string
  createTime: Date
}

// // 查询短信渠道列表
// export const getSmsChannelPage = (params: PageParam) => {
//   return request.get({ url: '/system/sms-channel/page', params })
// }
//
// // 获得短信渠道精简列表
// export function getSimpleSmsChannelList() {
//   return request.get({ url: '/system/sms-channel/simple-list' })
// }
//
// // 查询短信渠道详情
// export const getSmsChannel = (id: number) => {
//   return request.get({ url: '/system/sms-channel/get?id=' + id })
// }
//
// // 新增短信渠道
// export const createSmsChannel = (data: SmsChannelVO) => {
//   return request.post({ url: '/system/sms-channel/create', data })
// }
//
// // 修改短信渠道
// export const updateSmsChannel = (data: SmsChannelVO) => {
//   return request.put({ url: '/system/sms-channel/update', data })
// }
//
// // 删除短信渠道
// export const deleteSmsChannel = (id: number) => {
//   return request.delete({ url: '/system/sms-channel/delete?id=' + id })
// }
